import { addCsvData } from "../csv";

export enum NavacationAction {
    Click = 'Click', // 点击事件
    Auto = 'Auto' // 自动事件 (通过特殊指令，自动触发的一系列事件)
}

// 导航Widget
export enum NavagationWidget {
    NavagationMenu = 'NavagationMenu', // 菜单导航
    NavagationMain = 'NavagationMain', // 主界面导航
}

// 菜单导航事件ID
export enum NavagationMenuEventID {
    NavagationMenuMap = 'NavagationMenuMap', // 导航 -> 地图
    NavagationMenuHome = 'NavagationMenuHome', //导航 -> 首页
    NavagationMenuMusic = 'NavagationMenuMusic', //导航 -> 音乐
    NavagationMenuSetting = 'NavagationMenuSetting', //导航 -> 设置
    NavagationMenuCar = 'NavagationMenuCar', //导航 -> 汽车3D展示
}

// 主界面导航事件ID
export enum NavagationMainEventID {
    NavagationMainMap = 'NavagationMainMap', // 导航 -> 地图
    NavagationMainMusic = 'NavagationMainMusic', //导航 -> 音乐
    NavagationMainCar = 'NavagationMainCar', //导航 -> 汽车3D展示
}

// 自动导航事件ID
export enum NavagationAutoEventID {
    NavagationAutoMap = 'NavagationAutoMap', // 导航 -> 地图
    NavagationAutoMusic = 'NavagationAutoMusic', //导航 -> 音乐
}

// 导航事件
function eventNavagation(action: NavacationAction.Auto, widget: null, eventKey: NavagationAutoEventID): void;
function eventNavagation(action: NavacationAction.Click, widget: NavagationWidget.NavagationMenu, eventKey: NavagationMenuEventID): void;
function eventNavagation(action: NavacationAction.Click, widget: NavagationWidget.NavagationMain, eventKey: NavagationMainEventID): void;

function eventNavagation(action: NavacationAction, widget: NavagationWidget | null, eventKey: NavagationMainEventID | NavagationMenuEventID | NavagationAutoEventID): void {
    const data = { app: "Main", event_key: eventKey, data_json: { action, widget_type: widget, widget_id: widget ? eventKey : "" } };
    addCsvData(data);
}
export { eventNavagation }